﻿using System;
using System.Windows;
using SecuritySpace.ProtoType;
using SmartPeople.Framework.SecuritySpace;

namespace SecuritySpace.ProtoType
{
    public partial class MainMenu
    {
        private ISecuritySpaceProviderFactory securitySpaceProviderFactory = new XPOProviderFactory();

        public MainMenu()
        {
            InitializeComponent();
            InitializeSecurity();
        }

        private void cmdUsers_Click(object sender, RoutedEventArgs e)
        {
            Users users = new Users();
            users.Show();
        }

        private void cmdRoles_Click(object sender, RoutedEventArgs e)
        {
            Roles roles = new Roles();
            roles.Show();
        }

        private void cmdUserRoles_Click(object sender, RoutedEventArgs e)
        {
            RoleUsers roleusers = new RoleUsers();
            roleusers.Show();
        }

        private void cmdExit_Click(object sender, RoutedEventArgs e)
        {
            Application.Current.Shutdown(0);
        }

        private void InitializeSecurity()
        {
            try
            {
                ISecuritySpace securitySpace = securitySpaceProviderFactory.GetSecuritySpace();
                securitySpace.Clear();
                securitySpace.Intializer.Intialize(securitySpace);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
    }
}